<?php

namespace FoxLib\Controllers;

use Illuminate\Http\Request;
use Laravel\Lumen\Routing\Controller;
use Psr\Log\LoggerInterface;

class BaseController extends Controller
{
    protected $request;

    protected $userId;

    /** @var LoggerInterface $logger */
    protected $logger;

    public function __construct(Request $request)
    {
        $this->request = $request;
        $this->userId = (int)$request->header("X-Authenticated-Userid");
        $this->logger = app('log');
    }

    public function sendSuccessJson($data = '', $msg = '', $code = 0)
    {
        return response()->json([
            'data' => $data,
            'msg' => $msg,
            'code' => $code
        ]);
    }

    public function nowTimestamp()
    {
        return date('Y-m-d H:i:s');
    }
}
